package com.tech.zhidengxian.controller;

import com.tech.zhidengxian.model.dto.ChatDTO;
import com.tech.zhidengxian.model.dto.result.ReturnResult;
import com.tech.zhidengxian.model.dto.result.ReturnResultUtils;
import com.tech.zhidengxian.service.api.ChatService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/chat")
public class ChatController {
    @Resource
    private ChatService chatService;
    @RequestMapping("/queryChatListByUid")
    public ReturnResult<List<ChatDTO>> queryChatListByUid(Long uid){
        return ReturnResultUtils.returnSuccess(chatService.queryChatListByUid(uid));
    }

    @RequestMapping("/createOrLoadChat")
    public ReturnResult<ChatDTO> createOrLoadChat(@RequestBody ChatDTO chatDTO) {
        return ReturnResultUtils.returnSuccess(chatService.createOrLoadChat(chatDTO));
    }
}
